// 获取应用实例
const app = getApp()

Page({
	data: {
		img_src:app.globalData.img_src,
		// member_level:"帝王黑卡"
		// member_level:"兰花钻卡"
		// member_level:"蜂姿金卡"
		member_level:"休眠客人",
		userinfo:"",
		popSubshow: false,
		clickable:true
	},
	onLoad(options) {
			//判断卡别
			var userinfo = wx.getStorageSync('memberinfo');

			this.setData({
				member_level:userinfo.member_level,
				userinfo:userinfo
			})
			console.log(this.data)
	},
	goPage:function(){
		wx.navigateTo({
			url: '/pages/share/share'
		})
	},
	subscribe:function(){
		console.log(this.data.clickable)
		if(this.data.clickable == false){
			
			return;
		}
		
		this.setData({clickable:false})
		console.log(this.data.clickable)
		var that = this;
		var data = {
      openid: that.data.userinfo.openid,
		};
		wx.request({
			url: app.globalData.apiurl+'access.php?a=subscribe', 
			header: {
				"Content-Type": "application/x-www-form-urlencoded"
			},
			data: data,
			method:"POST",
			success (res) {
				if(res.data.status=="1"){
					that.setData({
						popSubshow:true,
						clickable:true
					})
				}else{
					that.setData({
						clickable:true
					})
					wx.showToast({
						title: res.data.info,
						icon:'none',
						duration:1500
					})
				
				}
				
			}
		})
		
	},
	closeBtn:function(){
		this.setData({
			popSubshow:false
		})
	},
})
